package com.daoeping.action;

import java.util.ArrayList;
import java.util.List;
import com.daoeping.domain.Bsc_specialty;
import com.daoeping.domain.JsonData;
import com.daoeping.service.SpecialtyService;
import com.daoeping.util.ConverntJsonData;
import com.opensymphony.xwork2.ActionSupport;

public class SpecialtyAction extends ActionSupport{
	
	private static final long serialVersionUID = -4609025966739152938L;
	private SpecialtyService specialtyService;
	private JsonData jsonData;
	private List<Bsc_specialty> specialtylist;
	
	public List<Bsc_specialty> getSpecialtylist() {
		return specialtylist;
	}

	public void setSpecialtylist(List<Bsc_specialty> specialtylist) {
		this.specialtylist = specialtylist;
	}

	public JsonData getJsonData() {
		return jsonData;
	}

	public void setJsonData(JsonData jsonData) {
		this.jsonData = jsonData;
	}

	public SpecialtyService getSpecialtyService() {
		return specialtyService;
	}

	public void setSpecialtyService(SpecialtyService specialtyService) {
		this.specialtyService = specialtyService;
	}

	public String findAllSpecialty(){
		jsonData = new JsonData();
		specialtylist = specialtyService.findBsc_specialties();
		List <String[]> strList = new ArrayList<String[]>();
		for (Bsc_specialty bsc_specialty : specialtylist) {
			String [] strarr = new String[2];
			strarr[1] = bsc_specialty.getId()+"";
			strarr[0] = bsc_specialty.getName();
			strList.add(strarr);
		}
		jsonData.setJsonData( new ConverntJsonData().getJsonData(strList)+"");
		return "allspecialty";
		
	}
	
}
